package gayatrirathore.app.adapter;

import java.util.Random;
import java.util.Vector;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RadialGradient;
import android.graphics.Typeface;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import ravishankar.app.hindi2englishsms.R;



public class SmsCategoriesAdapter extends BaseAdapter {

	Context context;
	Typeface font;
	LayoutInflater mInflater;
	Vector responseVector;

	int bg_arr[]=new int[]{R.drawable.yellow_gradient,R.drawable.blue_gradient,R.drawable.redgradient,R.drawable.green_gradient,R.drawable.purple_gradient,R.drawable.blue,R.drawable.yellow_gradient};
	String strCategoryArr[]=new String[]{"Friendship","Love","Shayri","Joke","Other"};

	public SmsCategoriesAdapter(Context context) {
		super();
		this.context = context;
		this.responseVector = responseVector;
		font=Typeface.createFromAsset(context.getAssets(), "comic.TTF");  
	
	}
	
	/* (non-Javadoc)
	 * @see android.widget.Adapter#getCount()
	 */
	public int getCount() {
		// TODO Auto-generated method stub
//		return ;
		return strCategoryArr.length;
	}

	/* (non-Javadoc)
	 * @see android.widget.Adapter#getItem(int)
	 */
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	/* (non-Javadoc)
	 * @see android.widget.Adapter#getItemId(int)
	 */
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	/* (non-Javadoc)
	 * @see android.widget.Adapter#getView(int, android.view.View, android.view.ViewGroup)
	 */
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		
		
		mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		convertView = mInflater.inflate(R.layout.smscategorieslist_row, parent, false);
	
		if(convertView==null||convertView.getTag()==null)
		{
			Random randfact = new Random();
			ViewHolder mViewHolder = new ViewHolder();
			mViewHolder.tvSms=(TextView)convertView.findViewById(R.id.tvSmsCategory);
			
			mViewHolder.tvSms.setTypeface(font);
			mViewHolder.tvSms.setText(strCategoryArr[position]);
			mViewHolder.tvSms.setBackgroundResource(bg_arr[position%bg_arr.length]);
		
		
			convertView.setTag(mViewHolder);
		}
		return convertView;
		
	}
	
	private class ViewHolder {
		

		private TextView tvSms;

	}

	private Drawable makeRadGrad() {
	    RadialGradient gradient = new RadialGradient(200, 200, 200, 0xFFFFFFFF,
	            0xFF000000, android.graphics.Shader.TileMode.CLAMP);
	    Paint p = new Paint();
	    p.setDither(true);
	    p.setShader(gradient);

	    Bitmap bitmap = Bitmap.createBitmap(400, 400, Config.ARGB_8888);
	    Canvas c = new Canvas(bitmap);
	    c.drawCircle(200, 200, 200, p);
	    Drawable drawable = (Drawable)new BitmapDrawable(bitmap);
	    return drawable;
	}
}
;